# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=tangctl
pkgver=0_git20220412
_gitrev=2c7f9b676e1571a5805b2e47502ac16e1dfba5da
pkgrel=13
pkgdesc="Tool implementing server-side ECMR exchange functionality (Tang server)"
url="https://github.com/anatol/tang.go"
license="BSD-3-Clause"
arch="all"
makedepends="go"
checkdepends="clevis tang"
source="https://github.com/anatol/tang.go/archive/$_gitrev/tang.go-$pkgver.tar.gz
	tang-location.patch
	"
builddir="$srcdir/tang.go-$_gitrev"
# generated key does not match hardcoded id
# probably cause by go version?
options="!check"

case "$CARCH" in
	# blocked by clevis
	s390x|riscv64) options="!check" ;;
esac

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOPATH="$srcdir"
export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build ./cmd/tangctl
}

check() {
	go test ./...
}

package() {
	install -Dm755 tangctl -t "$pkgdir"/usr/bin/
}

sha512sums="
6485cbfba2116b21fb5974dd3ef1dae1b5b8d39d8112e850f44941dc45896f6751b265b9e978b53f0e81520dce443ba2288b6b297bdac0d426ffecc46109baa6  tang.go-0_git20220412.tar.gz
22d1dac2321c9e2fe7c1e5559d3976f759941d9aef27e8c0fc7858e311243635560d235c228ad846f58743e7d3c76737ce8bec3c844a4f567a8604b279961dd4  tang-location.patch
"
